package cn.edu.scau.cmi.wujiaxian.exercise10;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Example10_16 {
	
	//Scanner解析文件
	public static void main(String[] args) {
		File file = new File("student1.txt");
		Scanner scanner = null;
		int count = 0;
		double sum = 0;
		try {
			double score = 0;
			scanner = new Scanner(file);
			scanner.useDelimiter("[^0123456789.]+");
			while (scanner.hasNextDouble()) {
				score = scanner.nextDouble();
				count++;
				sum += score;
				System.out.println(score);
			}
			System.out.println(sum / count);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
}
